<template>
  <div class="wrapper">
    <div style="margin: 200px auto; background-color: #fff; width: 350px; height: 450px; padding: 20px; border-radius: 10px">
      <div style="margin: 20px 0; text-align: center; font-size: 24px"><b>注 册</b></div>
      <el-input placeholder="请输入学号" size="medium" style="margin: 10px 0" prefix-icon="el-icon-edit" v-model="form.codeName"></el-input>
      <el-input placeholder="请输入姓名" size="medium" style="margin: 10px 0" prefix-icon="el-icon-s-custom" v-model="form.name"></el-input>
      <el-input placeholder="请输入电话" size="medium" style="margin: 10px 0" prefix-icon="el-icon-mobile-phone" v-model="form.phone"></el-input>
      <el-input placeholder="请输入账号" size="medium" style="margin: 10px 0" prefix-icon="el-icon-user" v-model="form.username"></el-input>
      <el-input placeholder="请输入密码" size="medium" style="margin: 10px 0" prefix-icon="el-icon-lock" show-password v-model="form.password"></el-input>
      <el-input placeholder="请确认密码" size="medium" style="margin: 10px 0" prefix-icon="el-icon-lock" show-password v-model="form.confirmpassword"></el-input><!--确认密码-->
      <div style="margin: 10px 0; text-align: right">
        <el-button type="primary" size="small" autocomplete="off" @click="login">确定</el-button>
        <el-button type="warning" size="small" autocomplete="off" @click="$router.push('/login')">返回登录</el-button>
      </div>
    </div>
  </div>
</template>

<script>
	import {user_add} from '../axios/api/userApi.js'
export default {
  name: "Login",
  data(){
    return{
      form:{
		  status: 1
	  }//把form对象发给后台，让后台校验form里面的属性
    }
  },
  methods:{

    //登录验证
    login(){
		console.log(this.user)
      if(this.user.password !== this.user.confirmpassword){
        this.$message.error("两次输入的密码不一致")
        return false
      }
      user_add(this.user).then(res=>{
		  this.$message.success("注册成功")
		  this.$router.push("/login")
	  })
    }
  }
}
</script>

<style>
.wrapper{
  height: 100vh;
  background-image: linear-gradient(to bottom right,#FC466B,#3F5EFB);
  overflow: hidden;
}
</style>